
#include "tower.h"
#include "animation.h"
#include "gamedatamanager.h"
#include "resourcemanager.h"

int Tower::SEED = 1;

Tower::Tower(const Point& pos):
	position(pos)
{
	id = SEED++;
	attribute.skillAttribute.newId();
}

Tower::~Tower() {
}

void Tower::init(){

}

bool Tower::update(float ticks) {
	return true;
}

bool Tower::ellipseContains(const Point& pos) {
	float range = attribute.range;

	float ew = range + range;
	float eh = ew * 0.7f;
	float ex = position.x - range;
	float ey = position.y - eh / 2.0f;

	float x = pos.x;
	float y = pos.y;

	// Normalize the coordinates compared to the ellipse
	// having a center at 0,0 and a radius of 0.5.
	if (ew <= 0.0f || eh <= 0.0f) {
		return false;
	}

	float normx = (x - ex) / ew - 0.5f;
	float normy = (y - ey) / eh - 0.5f;

	return (normx * normx + normy * normy) < 0.25f;
}

